#!/bin/sh

cd `dirname "$0"`

OLDDIR="sprites"
NEWDIR="new_sprites"

gen_img()
{
	if [ -f "$1" ]; then
		NEWFILE=`echo $1 | sed "s/^$2/$3/"`
		mkdir -p `dirname "$NEWFILE"`
		echo "$1 ---> $NEWFILE"
		convert $1 -resize 25% "$NEWFILE"
	fi
}

mkdir -p "${NEWDIR}"

export -f gen_img
find "${OLDDIR}" -exec sh -c "gen_img {} ${OLDDIR} ${NEWDIR}" \;

echo
